package com.keon.jianbao.ui.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;

import com.keon.jianbao.R;
import com.keon.jianbao.base.BaseActivity;
import com.keon.jianbao.enu.ListType;

/**
 * Created by keon on 2015/9/8.
 */
public class ListActivity extends BaseActivity {

    ListType type;

    FragmentManager fragmentManager;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_list;
    }

    @Override
    protected int getToolBarTitle() {
        return type.getTitle();
    }

    @Override
    public void initView() {
        Bundle bundle = getIntent().getExtras();

        type = ListType.getList(bundle.getInt("type"));

        fragmentManager = getSupportFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();

        try {
            ft.replace(R.id.list, (Fragment) (type.getClz().newInstance())).commit();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void initData() {

    }

    @Override
    public void onClick(View view) {

    }
}
